Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Conform to nitro's DataAvailabilityProvider interface #1

Draft
wants to merge 4 commits into
base: eigenda
Choose a base branch
from

Conversation

afkbyte
Copy link
Contributor

@afkbyte afkbyte commented Apr 6, 2024

todo: test

@afkbyte afkbyte requested a review from teddyknox April 6, 2024 19:44
Copy link

@ethenotethan ethenotethan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool - mostly stylistic and knits. Have a few questions and change requests 🚀

Comment on lines 850 to +851
use4844 bool,
useEigenDA bool,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: feel like an enum (e.g, DataSource) would be the best representation for this

if use4844 {

if useEigenDA {
calldata, err = method.Inputs.Pack(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should prolly be checking this error

if err != nil {
if config.DisableEigenDAFallbackStoreDataOnChain {
log.Warn("Falling back to storing data on chain", "err", err)
return false, errors.New("unable to post batch to EigenDA and fallback storing data on chain is disabled")
}
}

pointer, err := b.eigenDAWriter.Serialize(daRef)
pointer, err := b.eigenDAWriter.Serialize(blobID)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not?

Suggested change
pointer, err := b.eigenDAWriter.Serialize(blobID)
sequencerMsg, err = b.eigenDAWriter.Serialize(blobID)

sequencerMsg = pointer
}

data, kzgBlobs, err := b.encodeAddBatch(new(big.Int).SetUint64(batchPosition.NextSeqNum), batchPosition.MessageCount, b.building.msgCount, sequencerMsg, b.building.segments.delayedMsg, b.building.use4844)
data, kzgBlobs, err := b.encodeAddBatch(new(big.Int).SetUint64(batchPosition.NextSeqNum), batchPosition.MessageCount, b.building.msgCount, sequencerMsg, b.building.segments.delayedMsg, b.building.use4844, true, blobInfo)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we be binding this boolean as a config value to the building type?


// in the case of eigenDA the serialized data looks like this
// [0-40] Header Vals
// [40-41]eigenDA header flag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
// [40-41]eigenDA header flag
// [40-41] eigenDA header flag

@@ -211,3 +339,139 @@ func RecoverPayloadFromEigenDABatch(ctx context.Context,
}
return data, nil
}

// calldata layout of sequencer msg

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT - could be more readable to map this doc string into the function directly


}

func convertCalldataToInt(calldata []byte) (int, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - bytestoInt. Calldata implies that its being fed the calldata for the whole tx

num := new(big.Int).SetBytes(calldata)

if num.IsInt64() {
return int(num.Uint64()), nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for this casting? Could we ever receive a negative value input in this function?

"testing"
)

func TestParseSequencerMsg(t *testing.T) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - maybe we could leverage the existing nitro test helpers for this to make it more idiomatic with the repo design

@@ -0,0 +1,131 @@
package eigenda_blobs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not at a point yet where I could comfortably review this section. Would it be worth getting one of our kzg SMEs to take a look?

@Tristan-Wilson
Copy link
Contributor

Hi, we are doing some more work on further changes to the DA interface in Nitro and would welcome any feedback OffchainLabs/nitro#2157

new(big.Int).SetUint64(uint64(prevMsgNum)),
new(big.Int).SetUint64(uint64(newMsgNum)),
)
kzgBlobs, err = blobs.EncodeBlobs(l2MessageData)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we override this? If not mistaken this is using the same encoding for 4844 blobs

go 1.20
go 1.21

toolchain go1.21.0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This make error build on my docker local build


RUN go mod download
go: errors parsing go.mod:
/workspace/go.mod:5: unknown directive: toolchain

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If remove the toolchain go1.21.0 then an error on building smart contract happen as below

11.25 $ hardhat compile
22.44 Error HH411: The library eigenda, imported from src/bridge/ISequencerInbox.sol, is not installed. Try installing it using npm.
22.44 HardhatError: HH411: The library eigenda, imported from src/bridge/ISequencerInbox.sol, is not installed. Try installing it using npm.
22.44     at Resolver.resolveImport (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:254:15)
22.44     at async /workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:188:28
22.44     at async Promise.all (index 3)
22.44     at async DependencyGraph._addDependenciesFrom (/workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:186:5)
22.44     at async Promise.all (index 17)
22.44     at async Function.createFromResolvedFiles (/workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:15:5)
22.44     at async Environment._runTaskDefinition (/workspace/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
22.44     at async Environment.run (/workspace/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
22.44     at async SimpleTaskDefinition.action (/workspace/contracts/node_modules/hardhat/src/builtin-tasks/compile.ts:1346:58)
22.44     at async Environment._runTaskDefinition (/workspace/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
22.44
22.44     Caused by: HardhatError: HH401: Library eigenda is not installed.
22.44         at Resolver._resolveLibrarySourceName (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:322:15)
22.44         at Resolver.resolveSourceName (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:103:33)
22.44         at async Resolver.resolveImport (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:194:24)
22.44         at async /workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:188:28
22.44         at async Promise.all (index 3)
22.44         at async DependencyGraph._addDependenciesFrom (/workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:186:5)
22.44         at async Promise.all (index 17)
22.44         at async Function.createFromResolvedFiles (/workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:15:5)
22.44         at async Environment._runTaskDefinition (/workspace/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
22.44         at async Environment.run (/workspace/contracts/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
22.44
22.44         Caused by: Error: Cannot find module 'eigenda/package.json' from '/workspace/contracts'
22.44             at Function.resolveSync [as sync] (/workspace/contracts/node_modules/hardhat/node_modules/resolve/lib/sync.js:89:15)
22.44             at Resolver._resolveNodeModulesFileFromProjectRoot (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:457:20)
22.44             at Resolver._resolveLibrarySourceName (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:311:30)
22.44             at Resolver.resolveSourceName (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:103:33)
22.44             at async Resolver.resolveImport (/workspace/contracts/node_modules/hardhat/src/internal/solidity/resolver.ts:194:24)
22.44             at async /workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:188:28
22.44             at async Promise.all (index 3)
22.44             at async DependencyGraph._addDependenciesFrom (/workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:186:5)
22.44             at async Promise.all (index 17)
22.44             at async Function.createFromResolvedFiles (/workspace/contracts/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:15:5)
22.47
22.64 error Command failed with exit code 1.
22.65 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
22.69 make: *** [Makefile:336: .make/solidity] Error 1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants